zz_

test/index.test.js

zzmq.dev@gmail.com[dev3]/mathkit[add-median-numbers-function-returns] / test / index.test.js @ e84ab4c7 Download
Ladder Summary
  • file This file contains a suite of tests for the sum function, covering various scenarios including positive numbers, a mix of negative and positive numbers, an empty array input, and handling large datasets.
import { test } from "node:test";
import assert from "node:assert/strict";
import { sum } from "../index.js";

test("sum with positive numbers", () => {
  assert.strictEqual(sum(1, 2, 3), 6);
});

test("sum with negative and positive numbers", () => {
  assert.strictEqual(sum(-1, 1, -2, 2), 0);
});

test("sum of empty array", () => {
  assert.strictEqual(sum(), 0);
});

test("sum of large dataset", () => {
  const largeDataset = Array.from({ length: 1000 }, (_, i) => i + 1);
  assert.strictEqual(sum(...largeDataset), (1000 * 1001) / 2);
});